#include<bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 1;
struct car{
    int vel,a,dis;
    bool jud = 0;
    queue<int> q;
}c[MAXN];
double vt(car x,int loc){
    if(x.a == 0) return double(x.vel);
    double v0 = x.vel,A = x.a,lo = loc - x.dis;
    double nv = v0 * v0 + 2 * A * lo;
    if(nv > 0) return sqrt(nv);
    return 0;
}
struct ppp{
    int plc;
    bool op = 0;
}p[MAXN];
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int T,n,m,L,V;
    cin >> T;
    while(T--){
        cin >> n >> m >> L >> V;
        for(int i = 1;i <= n;++i){
            cin >> c[i].dis >> c[i].vel >> c[i].a;
        }
        for(int i = 1;i <= m;++i){
            cin >> p[i].plc;
        }
        for(int i = 1;i <= m;i++){
            for(int j = 1;j <= n;j++){
                if(c[j].dis > p[i].plc) continue;
                if(vt(c[j],p[i].plc) > V){
                    p[i].op = 1;
                    c[j].jud = 1;
                    c[j].q.push(i);
                }
            }
        }
        int cnt = 0;
        for(int i = 1;i <= n;i++){
            if(c[i].jud) cnt++;
        }
        int tot = 0;
        for(int i = 1;i <= m;i++){
            if(p[i].op == 0) tot++;
        }
        cout << cnt << " " << tot + ((n - tot) >> 1);
    }
    fclose(stdin);
    fclose(stdout);
    return 0;
}
